package com.xy.cloud.controller;

import com.xy.cloud.domain.R;
import com.xy.cloud.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {
    private static final Logger log = LoggerFactory.getLogger(OrderController.class);
    @Autowired
    private OrderService orderService;

    /**
     *  【rocketmq】 分布式事务
     */
    @PostMapping("/order/delete")
    public R<String> delete(@RequestParam String orderNo){
        log.info("delete order id is {}",orderNo);
        orderService.delete(orderNo);
        return R.ok("订单删除成功");
    }

    /**
     * 【seata】 分布式事务
     */
    @PostMapping("/order/save")
    public R<?> save(){
        orderService.save();
        return R.ok();
    }

}
